
PiecePawn.prototype = new Piece();

function PiecePawn(io_obj, color_str){
	/** HERITAGE */
	this.parent = Piece;
	this.parent (io_obj, color_str);

	/** PRIVATE */

	/** PUBLIC */
	this._constructor = function piecePawn__constructor (io_obj, color_str) {
		this._type = "pawn";
	}

	this.canMoveTo = function piecePawn_canMoveTo (loc_obj) {
		var old_loc_obj, result;
		old_loc_obj = this.getLocation ();

		this._io.print("PiecePawn.canMoveTo -- ");
		var move_obj = new MoveLinear (
				this.getIO (), 
				this, 
				old_loc_obj, 
				loc_obj
				);

		if ((this.getColor() == this.COLOR_WHITE) 
				&& (old_loc_obj.getY() == 6))
		{
			move_obj.setMaxDistance (2);
		} else {
			if ((this.getColor() == this.COLOR_BLACK)
					&& (old_loc_obj.getY() == 1))
			{
				move_obj.setMaxDistance (2);
			} else {
				move_obj.setMaxDistance (1);
			}
		}

		result = false; // by default

		if (move_obj.isVertical() 
				&& move_obj.isPossible() 
				&& !move_obj.isATake()
				&& move_obj.isForward())
		{
			result = true;
		} else {
			move_obj.setMaxDistance (1);
			if (move_obj.isDiagonal()
					&& move_obj.isPossible()
					&& move_obj.isATake()
					&& move_obj.isForward()) {
				result = true;
			} else {
				result = false;
			}
		}

		return result;
	}

	/** CONSTRUCT ! */
	this._constructor (io_obj, color_str);
}
